package com.baize.cpdepus.controller;

import com.baize.cpdepus.common.R;
import com.baize.cpdepus.entity.Comment;
import com.baize.cpdepus.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/Comment")
@Slf4j
@CrossOrigin
@Api(value = "评论操作",tags = "评论操作接口")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @GetMapping
    @ApiOperation(value = "分页查询评论")
    public R<List<Comment>> lookAll(
            @ApiParam(value = "页码", required = true)
            Integer current,
            @ApiParam(value = "物品ID", required = true)
            Integer article) {
        return commentService.lookAll(current, article);
    }

    @PostMapping
    @ApiOperation(value = "新增一条评论")
    public boolean insertOneUpVote(
            @ApiParam(value = "物品信息", required = true)
            @RequestBody Comment comment) {
        return commentService.insertOneUpVote(comment);
    }
}
